<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <% include ../../ejs/_meta.ejs %>
    <title>选择收货地址</title>
    <% include ../../ejs/_css.ejs %>
    <link rel="stylesheet" type="text/css" href="../../css/address/list.css" inline>
</head>

<body class="body-bg" ontouchstart>
    <div class="m-page">
        <%-include("../../ejs/_header.ejs", {title: '选择收货地址'}) %>
        <section class="m-content">
            <div class="m-blocks">
                <!-- 无收货地址 -->
                <div class="m-nodata none">
                    <i class="iconfont icon-nodata"></i>
                    <p class="n-title">您还未添加任何收货地址<br>点击下方按钮新增</p>
                </div>
                <!-- 有收货地址 -->
                <div class="m-block">
                    <div class="b-info" data-id="1">
                        <div class="i-base"><span class="fl">李小广</span><span class="fr">15711559464</span></div>
                        <div class="i-detail">福建省晋江市象山街道洪山文创园尚之坊创意园607室（阿米古网络科技有限公司）</div>
                    </div>
                    <div class="b-btns">
                        <span class="b-btn edit"><i class="iconfont icon-edit"></i>编辑</span>
                        <span class="b-btn delete" data-id="1"><i class="iconfont icon-delete"></i>删除</span>
                    </div>
                </div>
                <div class="m-block">
                    <div class="b-info" data-id="1">
                        <div class="i-base"><span class="fl">李小广</span><span class="fr">15711559465</span></div>
                        <div class="i-detail">福建省厦门市思明区高雄路18号通达大厦203</div>
                    </div>
                    <div class="b-btns">
                        <span class="b-btn edit"><i class="iconfont icon-edit"></i>编辑</span>
                        <span class="b-btn delete" data-id="1"><i class="iconfont icon-delete"></i>删除</span>
                    </div>
                </div>
                <div class="m-block">
                    <div class="b-info" data-id="2">
                        <div class="i-base"><span class="fl">李小广</span><span class="fr">15711559466</span></div>
                        <div class="i-detail">福建省厦门市思明区莲前街道二轻大厦602室</div>
                    </div>
                    <div class="b-btns">
                        <span class="b-btn edit"><i class="iconfont icon-edit"></i>编辑</span>
                        <span class="b-btn delete" data-id="2"><i class="iconfont icon-delete"></i>删除</span>
                    </div>
                </div>
            </div>
        </section>
        <div class="m-add"><i class="iconfont icon-add"></i>新增地址</div>
    </div>
</body>

<%-include("../../ejs/_js.ejs", {env: env}) %>
<script type="text/javascript">
$(function () {
    var _orderId = utils.param('id');

    $('.m-block').m_delegate('.delete', function () {
        var $this = $(this);
        var id = $this.data('id');
        var $block = $this.parents('.m-block');

        $.confirm('是否确定删除该地址？', function () {
            //- 模拟删除
            $.showLoading({text: '删除中...'});
            setTimeout(function () {
                $.hideLoading();
                $.toast('删除成功', function () {
                    $block.slideUp('fast', function () {
                        this.remove();

                        var len = $('.m-block').length;
                        if (len == 0) {
                            //- 显示无数据情况
                            $('.m-nodata').removeClass('none');
                        }
                    });
                });
            }, 1200);

            // $.post('url', {id: id}, function (data) {

            // });
        });
    }).m_delegate('.edit', function() {
        //- 编辑
        var $this = $(this);
        var id = $this.data('id');
        jump.view('address/edit.html?id=' + id);
    });


    //- 新增地址
    $('.m-add').m_touch(function() {
        jump.view('address/edit.html');
    })
});
</script>

</html>
